
class RespModel {
    constructor(data, msg = '操作成功', options) {
        this.status=false;
        this.data = null
        if (arguments.length === 0) {
          this.msg = '操作成功'
        } else if (arguments.length === 1) {
          this.msg = data
        } else {
          this.data = data
          this.msg = msg
          if (options) {
            this.options = options
          }
        }
    }
    createResp(){
      let base={
        status:this.status,
        msg:this.msg
      }
      if(this.data){
        base.data=this.data;
      }
      if(this.options){
        base={...base,...this.options}
      }
      return base;
    }
    success(){
        this.status=true;
        return this.createResp();
    }
    error(){
        this.status=false;
        return this.createResp();
    }

}

module.exports=RespModel